<?php
namespace app\validate;

use think\Validate;

class AddUserValidate extends Validate
{
    protected $rule = [
        'username'  => 'require|min:3|max:20',
        'password'  => 'require|min:6|max:20',
        'real_name' => 'require|max:20',
        'role'      => 'require|in:admin,teacher,student'
    ];

    protected $message = [
        'username.require'  => '用户名不能为空',
        'username.min'      => '用户名长度不能小于3个字符',
        'username.max'      => '用户名长度不能超过20个字符',
        'password.require'  => '密码不能为空',
        'password.min'      => '密码长度不能小于6个字符',
        'password.max'      => '密码长度不能超过20个字符',
        'real_name.require' => '真实姓名不能为空',
        'real_name.max'     => '真实姓名长度不能超过20个字符',
        'role.require'      => '角色不能为空',
        'role.in'           => '角色必须是admin, teacher, student中的一个'
    ];
}